/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MaterialPack;

import Supporter.ImageSupporter;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author Van persie
 */
public class MaterialObject {
       
    //protected Image backUpImage = null;
    protected Image background = null;
    protected boolean  isVisible;
    
    protected int xPos;
    protected int yPos;
    
    protected int width;
    protected int height;
    
    private MaterialObject Owned;
    
    protected boolean  isPressed = false;
    public MaterialObject(){}
    
     public void LoadImage(String backgPath,boolean isTrans, int w,int h) {

         if(backgPath != null)
         {
            ImageSupporter imgSupp = new ImageSupporter();
            background = imgSupp.getImage(backgPath);
            if(w > 0 && h > 0)
                background = ImageSupporter.scaleImage(background, w, h);
            
            if(isTrans)
                background = ImageSupporter.transparent(background);
         }
    }
       
     public void Resize(int wid,int hei )
    {
        width = wid;
        height = hei;
        //backUpImage = ImageSupporter.scaleImage(backUpImage, wid, hei);
        if(background != null)
            background = ImageSupporter.scaleImage(background, wid, hei);
        
    }
    public void SetAlphaBack()
    {
        if(background != null)
            background = ImageSupporter.alphaBlend(ImageSupporter.scaleImage(background, width, height) );
    }
    public void TransBackground(boolean  decide)
    {
        if(background != null)
            background = ImageSupporter.transparent(ImageSupporter.scaleImage(background, width, height));
    }
    public void GetGraphicsInfo(int x, int y, int wid, int hei) {
        setxPos(x);
        setyPos(y);
        setWidth(wid);
        setHeight(hei);
    }
    public boolean isContained(int x, int y)
    {
        if( x > getxPos() && x < (getxPos() + getWidth()) && y > getyPos() && y < (getyPos() + getHeight()))
            return true;
        return false;
    }
    public void Check()
    {
        
    }
    public boolean Press(int x, int y)
    {
        return false;
    }
    public void Drag(int x, int y)
    {
    }
    public boolean Release(int x, int y)
    {
        return false;
    }
    public void paint(Graphics g)
    {
    }

    
    /**
     * @return the isVisible
     */
    public boolean IsVisible() {
        return isVisible;
    }

    /**
     * @param isVisible the isVisible to set
     */
    public void setIsVisible(boolean isVisible) {
        this.isVisible = isVisible;
    }

    /**
     * @return the Owned
     */
    public MaterialObject getOwned() {
        return Owned;
    }

    /**
     * @param Owned the Owned to set
     */
    public void setOwned(MaterialObject Owned) {
        this.Owned = Owned;
    }

    /**
     * @return the xPos
     */
    public int getxPos() {
        return xPos;
    }

    /**
     * @param xPos the xPos to set
     */
    public void setxPos(int xPos) {
        this.xPos = xPos;
    }

    /**
     * @return the yPos
     */
    public int getyPos() {
        return yPos;
    }

    /**
     * @param yPos the yPos to set
     */
    public void setyPos(int yPos) {
        this.yPos = yPos;
    }

    /**
     * @return the width
     */
    public int getWidth() {
        return width;
    }

    /**
     * @param width the width to set
     */
    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * @return the height
     */
    public int getHeight() {
        return height;
    }

    /**
     * @param height the height to set
     */
    public void setHeight(int height) {
        this.height = height;
    }
}
